package com.ruoyi.quartz.task;

import com.ruoyi.employee.mapper.EmployeeStaticMapper;
import com.ruoyi.employee.service.IEmployeeUserService;
import com.ruoyi.order.service.IOrderGoodsService;
import com.ruoyi.order.service.IOrderPkService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import com.ruoyi.common.utils.StringUtils;

/**
 * 定时任务调度测试 定时器
 * 
 * @author ruoyi
 */
@Component("ryTask")
public class RyTask
{

    @Autowired
    private EmployeeStaticMapper employeeStaticMapper;

    @Autowired
    private IEmployeeUserService employeeUserService;

    @Autowired
    private IOrderPkService orderPkService;

    @Autowired
    private IOrderGoodsService orderGoodsService;

    public void ryMultipleParams(String s, Boolean b, Long l, Double d, Integer i)
    {
        System.out.println(StringUtils.format("执行多参方法： 字符串类型{}，布尔类型{}，长整型{}，浮点型{}，整形{}", s, b, l, d, i));
    }

    public void ryParams(String params)
    {
        System.out.println("执行有参方法：" + params);
    }

    public void ryNoParams()
    {
        System.out.println("执行无参方法");
    }

    // 每日重置数据 - 零点
    public void dayResetStatic()
    {
        System.out.println("每日零点执行：重置店员每日数据");
        employeeStaticMapper.dayResetUser();
    }

    // 每日重置数据 - 凌晨4点
    public void dayResetData()
    {
        System.out.println("每日凌晨4点执行：重置店员等级数据 + 结算PK单");
        employeeUserService.updateUserLevel();
        orderPkService.updateOrderPkSettle();
    }

    // 每分钟重置数据
    public void minuteResetData()
    {
        System.out.println("每隔 每分钟执行：查询更新店员PK数据 订单超时提醒 订单超时取消");
        orderPkService.updateOrderPkProgram();
        orderGoodsService.updateOrderGoodsOvertimeCancel();
        orderGoodsService.updateOrderGoodsOvertimeNotice();
    }
}
